<template>
  <div class="list">
    <div class="like">
      <p>猜你喜欢</p>
    </div>
    <div class="px">
      <span
        @click="pxsort(index)"
        v-for="(item, index) in pxArr"
        :key="index"
        >{{ item }}</span
      >
    </div>
    <div class="rm">
      <span v-for="(item, index) in rmArr" :key="index">{{ item }}</span>
    </div>
    <div class="shop" v-for="(item, index) in shopArr" :key="index">
      <div class="spjs">
        <div class="tp">
          <img :src="item.pic" alt="" />
        </div>
        <div class="name">
          <p>{{ item.name }}</p>
          <div class="pf">
            <span>{{ item.pf }}</span>
            <span>月售{{ item.ys }}</span>
          </div>
          <div class="ps">
            <span>起送￥{{ item.qs }}</span>
            <span>配送￥{{ item.ps }}</span>
            <span>{{ item.time }}分钟</span>
            <span>{{ item.km }}km</span>
          </div>
          <div class="mj">
            <span v-for="(item, index) in mjArr" :key="index">{{ item }}</span>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      pxArr: ["综合排序", "距离最近", "销量最高", "筛选"],
      rmArr: ["年货节热卖", "津贴联盟", "满减优惠", "品质联盟"],
      mjArr: ["35减12", "70减35", "100减45"],
      shopArr: [
        {
          pic: "http://p0.meituan.net/deal/ce27d7b711b5991fdfd78b820e35b557288464.png",
          name: "金百万烤鸭(苏家坨店)",
          pf: 4.3,
          ys: 1632,
          qs: 20,
          ps: 3,
          time: 47,
          km: 3.9,
        },
        {
          pic: "http://p0.meituan.net/deal/ce27d7b711b5991fdfd78b820e35b557288464.png",
          name: "稻香金源饺子馆",
          pf: 4.4,
          ys: 230,
          qs: 20,
          ps: 3.5,
          time: 44,
          km: 2.5,
        },
      ],
    };
  },
  methods: {
    pxsort(index) {
      if (index == 0) {
        this.shopArr.sort((a, b) => {
          return a.km - b.km;
        });
      }
      if (index == 2) {
        this.shopArr.sort((a, b) => {
          return b.ys - a.ys;
        });
      }
    },
  },
};
</script>

<style lang="scss">
.list {
  padding: 10px;
}
.list .like {
  font-size: 18px;
  font-weight: bolder;
}
.list .px {
  width: 100%;
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
}
.list .rm {
  width: 100%;
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
}
.list .rm span {
  background-color: #f5f5f5;
  padding: 10px;
  display: block;
  box-sizing: border-box;
  font-size: 14px;
  border-radius: 5px;
}
.shop {
  margin-top: 30px;
}
.shop .tp {
  float: left;
  margin-right: 10px;
}
.shop .spjs .tp img {
  width: 100px;
  height: 100px;
}
.shop .spjs .name p {
  font-weight: bolder;
  margin-bottom: 5px;
  font-size: 18px;
}
.shop .spjs .name .pf span {
  padding: 10px;
  font-size: 14px;
}
.shop .spjs .name .ps {
  margin-top: 5px;
}
.shop .spjs .name .ps span {
  padding: 5px;
  font-size: 14px;
}
.shop .spjs .name .mj {
  margin-top: 10px;
}
.shop .spjs .name .mj span {
  padding: 2px;
  margin-right: 5px;
  border: 1px solid red;
  font-size: 12px;
}
</style>